package edu.neu.cs6515.board;

import java.util.List;

import com.google.common.collect.ImmutableList;

import edu.neu.cs6515.util.Funct;

/**
 * Provides Funct<Hexagon, Hexagon> implementations to help to navigate in to
 * the 6 directions of a hexagon
 */
public final class HexagonDirection {

    /**
     * private c'tor for util class
     */
    private HexagonDirection() {
    }

    /**
     * function that return the Top neighbor
     */
    public static final Funct<Hexagon, Hexagon> TOP = new Funct<Hexagon, Hexagon>() {
        @Override
        public Hexagon exec(final Hexagon h) {
            return h.getTop();
        }
    };

    /**
     * function that return the TOPRIGHT neighbor
     */
    public static final Funct<Hexagon, Hexagon> TOPRIGHT = new Funct<Hexagon, Hexagon>() {
        @Override
        public Hexagon exec(final Hexagon h) {
            return h.getTopRight();
        }
    };
    /**
     * function that return the BOTTOMRIGHT neighbor
     */
    public static final Funct<Hexagon, Hexagon> BOTTOMRIGHT = new Funct<Hexagon, Hexagon>() {
        @Override
        public Hexagon exec(final Hexagon h) {
            return h.getBottomRight();
        }
    };

    /**
     * function that return the BOTTOM neighbor
     */
    public static final Funct<Hexagon, Hexagon> BOTTOM = new Funct<Hexagon, Hexagon>() {
        @Override
        public Hexagon exec(final Hexagon h) {
            return h.getBottom();
        }
    };
    /**
     * function that return the BOTTOMLEFT neighbor
     */
    public static final Funct<Hexagon, Hexagon> BOTTOMLEFT = new Funct<Hexagon, Hexagon>() {
        @Override
        public Hexagon exec(final Hexagon h) {
            return h.getBottomLeft();
        }
    };
    /**
     * function that return the TOPLEFT neighbor
     */
    public static final Funct<Hexagon, Hexagon> TOPLEFT = new Funct<Hexagon, Hexagon>() {
        @Override
        public Hexagon exec(final Hexagon h) {
            return h.getTopLeft();
        }
    };

    /**
     * @return List of Funct<Hexagon, Hexagon> for all 6 directions
     */
    public static List<Funct<Hexagon, Hexagon>> getAllDirections() {
        return ImmutableList.of(TOP, TOPRIGHT, BOTTOMRIGHT, BOTTOM, BOTTOMLEFT,
                TOPLEFT);
    }
}
